using MicroMsg.Common.Event;
using MicroMsg.Plugin;
using MicroMsg.UI.Page;
using MicroMsg.UI.Util;
using System;
using System.Diagnostics;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
namespace MicroMsg.UI.UserContrl
{
	public class PluginEntranceItemCtrl : UserControl
	{
		public delegate void ListItemClick(object sender, object object_0);
		private const string TAG = "PluginEntranceItemCtrl";
		public static DependencyProperty ListItemProperty = DependencyProperty.Register("ItemObject", typeof(PluginBase), typeof(PluginEntranceItemCtrl), new PropertyMetadata(null, new PropertyChangedCallback(PluginEntranceItemCtrl.OnItemPropertyChanged)));
		public static DependencyProperty strImageSourceProperty = DependencyProperty.Register("strImageSource", typeof(string), typeof(PluginEntranceItemCtrl), new PropertyMetadata(null, new PropertyChangedCallback(PluginEntranceItemCtrl.OnstrImageSourcePropertyChanged)));
		public static DependencyProperty strWordingProperty = DependencyProperty.Register("strWording", typeof(string), typeof(PluginEntranceItemCtrl), new PropertyMetadata(null, new PropertyChangedCallback(PluginEntranceItemCtrl.OnstrWordingPropertyChanged)));
		private bool mBIsFirstLoaded = true;
		private EventWatcher mWatchxxx;
		private object mObjectWatcher;
		internal ClickEffectGrid btnLayoutRoot;
		internal StackPanel panelItem;
		internal Image imgIcon;
		internal TextBlock txtTitle;
		internal TextBlock txtBtlCnt;
		private bool _contentLoaded;
		public event PluginEntranceItemCtrl.ListItemClick ItemClick;
		public PluginBase ItemObject
		{
			get
			{
				return (PluginBase)base.GetValue(PluginEntranceItemCtrl.ListItemProperty);
			}
			set
			{
				base.SetValue(PluginEntranceItemCtrl.ListItemProperty, value);
			}
		}
		public string strImageSource
		{
			get
			{
				return (string)base.GetValue(PluginEntranceItemCtrl.strImageSourceProperty);
			}
			set
			{
				base.SetValue(PluginEntranceItemCtrl.strImageSourceProperty, value);
			}
		}
		public string strWording
		{
			get
			{
				return (string)base.GetValue(PluginEntranceItemCtrl.strWordingProperty);
			}
			set
			{
				base.SetValue(PluginEntranceItemCtrl.strWordingProperty, value);
			}
		}
		public PluginEntranceItemCtrl()
		{
			this.InitializeComponent();
		}
		private static void OnItemPropertyChanged(DependencyObject dependencyObject_0, DependencyPropertyChangedEventArgs dependencyPropertyChangedEventArgs_0)
		{
			if (dependencyPropertyChangedEventArgs_0.get_Property() == PluginEntranceItemCtrl.ListItemProperty)
			{
				(dependencyObject_0 as PluginEntranceItemCtrl).OnListItemPropertyChanged(dependencyPropertyChangedEventArgs_0);
			}
		}
		private void OnListItemPropertyChanged(DependencyPropertyChangedEventArgs dependencyPropertyChangedEventArgs_0)
		{
			try
			{
				if (dependencyPropertyChangedEventArgs_0.get_OldValue() != dependencyPropertyChangedEventArgs_0.get_NewValue())
				{
					this.ItemObject.SetFFEntryCallBack(new StandardUITaskDlg(this.PluginCallBack));
					this.RefreshItem();
				}
			}
			catch (Exception ex)
			{
				ex.ToString();
			}
		}
		private static void OnstrImageSourcePropertyChanged(DependencyObject dependencyObject_0, DependencyPropertyChangedEventArgs dependencyPropertyChangedEventArgs_0)
		{
			if (dependencyPropertyChangedEventArgs_0.get_Property() == PluginEntranceItemCtrl.strImageSourceProperty)
			{
				(dependencyObject_0 as PluginEntranceItemCtrl).strImageSourcePropertyChanged(dependencyPropertyChangedEventArgs_0);
			}
		}
		private void strImageSourcePropertyChanged(DependencyPropertyChangedEventArgs dependencyPropertyChangedEventArgs_0)
		{
			try
			{
				object arg_0F_0 = dependencyPropertyChangedEventArgs_0.get_OldValue();
				object arg_0E_0 = dependencyPropertyChangedEventArgs_0.get_NewValue();
			}
			catch (Exception ex)
			{
				ex.ToString();
			}
		}
		private static void OnstrWordingPropertyChanged(DependencyObject dependencyObject_0, DependencyPropertyChangedEventArgs dependencyPropertyChangedEventArgs_0)
		{
			if (dependencyPropertyChangedEventArgs_0.get_Property() == PluginEntranceItemCtrl.strWordingProperty)
			{
				(dependencyObject_0 as PluginEntranceItemCtrl).strWordingPropertyChanged(dependencyPropertyChangedEventArgs_0);
			}
		}
		private void strWordingPropertyChanged(DependencyPropertyChangedEventArgs dependencyPropertyChangedEventArgs_0)
		{
			try
			{
				object arg_0F_0 = dependencyPropertyChangedEventArgs_0.get_OldValue();
				object arg_0E_0 = dependencyPropertyChangedEventArgs_0.get_NewValue();
			}
			catch (Exception ex)
			{
				ex.ToString();
			}
		}
		private void Control_Loaded(object sender, RoutedEventArgs e)
		{
		}
		private void Control_Unloaded(object sender, RoutedEventArgs e)
		{
		}
		private void registerEvent()
		{
			if (this.mWatchxxx == null)
			{
				this.mWatchxxx = new EventWatcher(this, null, new EventHandlerDelegate(this.Onxxx));
				EventCenter.registerEventWatcher(EventConst.ON_STORAGE_CONTACT_ADD, this.mWatchxxx);
			}
		}
		private void unRegisterEvent()
		{
			if (this.mWatchxxx != null)
			{
				EventCenter.removeEventWatcher(EventConst.ON_STORAGE_CONTACT_ADD, this.mWatchxxx);
				this.mWatchxxx = null;
			}
		}
		private void Onxxx(EventWatcher watcher, BaseEventArgs evtArgs)
		{
			if (evtArgs == null)
			{
				return;
			}
		}
		private void btnLayoutRoot_Click(object sender, object object_0)
		{
			if (this.ItemObject != null)
			{
				this.ItemObject.execute(3, null);
			}
			if (this.ItemClick != null)
			{
				this.ItemClick(this, this.ItemObject);
			}
		}
		public void RefreshItem()
		{
			if (this.ItemObject == null)
			{
				base.set_Visibility(1);
				return;
			}
			base.set_Visibility(0);
			this.imgIcon.set_Source(this.ItemObject.mIconInFFEntry);
			this.txtTitle.set_Text(this.ItemObject.mFFEntryTitle);
		}
		public object PluginCallBack(object obj1, object obj2)
		{
			if (!(obj1 is FFEntryCtrlOpKind))
			{
				return null;
			}
			FFEntryCtrlOpKind fFEntryCtrlOpKind = (FFEntryCtrlOpKind)obj1;
			FFEntryCtrlOpKind fFEntryCtrlOpKind2 = fFEntryCtrlOpKind;
			if (fFEntryCtrlOpKind2 == FFEntryCtrlOpKind.OpKind_Cnt)
			{
				if (obj2 is int)
				{
					int num = (int)obj2;
					if (num == 0)
					{
						this.txtBtlCnt.set_Visibility(1);
					}
					else
					{
						if (MMTheme.IsCoolBlackTheme())
						{
							TextBlock arg_6C_0 = this.txtBtlCnt;
							SolidColorBrush solidColorBrush = new SolidColorBrush();
							solidColorBrush.set_Color(Color.FromArgb(255, 96, 96, 96));
							arg_6C_0.set_Foreground(solidColorBrush);
						}
						else
						{
							TextBlock arg_9F_0 = this.txtBtlCnt;
							SolidColorBrush solidColorBrush2 = new SolidColorBrush();
							solidColorBrush2.set_Color(Color.FromArgb(255, 164, 204, 208));
							arg_9F_0.set_Foreground(solidColorBrush2);
						}
						this.txtBtlCnt.set_Text(string.Concat(num));
						this.txtBtlCnt.set_Visibility(0);
					}
				}
				return null;
			}
			return null;
		}
		[DebuggerNonUserCode]
		public void InitializeComponent()
		{
			if (this._contentLoaded)
			{
				return;
			}
			this._contentLoaded = true;
			Application.LoadComponent(this, new Uri("/MicroMsg;component/Source/UI/CommonUseControl/PluginEntranceItemCtrl.xaml", 2));
			this.btnLayoutRoot = (ClickEffectGrid)base.FindName("btnLayoutRoot");
			this.panelItem = (StackPanel)base.FindName("panelItem");
			this.imgIcon = (Image)base.FindName("imgIcon");
			this.txtTitle = (TextBlock)base.FindName("txtTitle");
			this.txtBtlCnt = (TextBlock)base.FindName("txtBtlCnt");
		}
	}
}
